package main

import (
	"fmt"
	"sync"
	"time"
)

func main() {
	var lock sync.Mutex
	go func() {
		lock.Lock()
		defer lock.Unlock()
		fmt.Printf("func1 get lock at %s \n", time.Now().String())
		time.Sleep(time.Second)
		fmt.Printf("func1 release lock%s \n", time.Now().String())
	}()
	time.Sleep(time.Second / 10)
	go func() {
		lock.Lock()
		defer lock.Unlock()
		fmt.Printf("func2 get lock at %s \n", time.Now().String())
		time.Sleep(time.Second)
		fmt.Printf("func2 release lock%s \n", time.Now().String())
	}()
	time.Sleep(time.Second * 4)
}
